{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=3183
  Verdict: Accepted
}
uses SysUtils, Math;
 
const pr:set of byte=[44, 46, 63, 33, 45, 58, 39];
 
var
   w,b,ls,i,q,cp,cd,ck,cnt:longint;
   s,t,sp,r,print,cop:ansistring;
   abz,prep,space:boolean;
 
begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
readln(w,b);
s:='}';
sp:='';
for i:=1 to b do sp:=sp+' ';
while not eof do begin
      readln(t);
      t:=trim(t);
      s:=s+t+' ';
      if t='' then s:=s+'}';
end;
ls:=length(s);
space:=false;
r:='';
for i:=1 to ls do begin
    if s[i]='}' then begin
       if length(r)>0 then begin
          if r[length(r)]<>'$' then r:=r+'$';
       end else r:=r+'$';
       space:=false;
    end else
    if ord(s[i]) in pr then begin
       space:=true;
       r:=r+s[i];
    end else
    if s[i]=' ' then space:=true else begin
       if space then r:=r+' ';
       space:=false;
       r:=r+s[i];
    end;
end;
q:=length(r);
while r[q] in [' ','$'] do begin
      delete(r,q,1);
      q:=length(r);
end;
ls:=length(r)-1;
print:=sp;
delete(r,1,1);
q:=b;
cnt:=0;
while ls>0 do begin
      cp:=pos(' ',r);
      if cp=0 then begin
         cp:=ls;
      end;
      cd:=pos('$',r);
      if cd=0 then cd:=maxlongint;
      if cd>1 then ck:=min(cp,cd-1) else ck:=cd;
      cop:=copy(r,1,ck);
      delete(r,1,ck);
      if cop='$' then begin
         if q>1 then begin
            while ((print[q]=' ') or (print[q]='$')) and (q>1) do begin
                  delete(print,q,1);
                  dec(q);
            end;
         end;
         if print<>'' then writeln(print);
         print:=sp;
         q:=b;
      end else
      if cop<>' ' then begin
      if (length(cop)<=w-q+1) then begin
         print:=print+cop;
         inc(q,ck);
         if (q=w) or (q=w+1) then begin
            if q>1 then begin
               while ((print[q]=' ') or (print[q]='$')) and (q>1) do begin
                     delete(print,q,1);
                     dec(q);
               end;
            end;
            if q<=w then begin
               writeln(print);
               q:=0;
               print:='';
            end else begin
                delete(print,q-ck+1,ck);
                dec(q,ck);
                if q>1 then begin
                   while ((print[q]=' ') or (print[q]='$')) and (q>1) do begin
                     delete(print,q,1);
                     dec(q);
                   end;
                end;
                writeln(print);
                q:=ck;
                print:=cop;
            end;
         end;
      end else begin
          if q>1 then begin
             while ((print[q]=' ') or (print[q]='$')) and (q>1) do begin
                delete(print,q,1);
                dec(q);
             end;
          end;
          if (ck<w-q) and (length(r)>0) then begin
             print:=print+' '+cop;
             inc(q,ck);
          end else begin
              writeln(print);
              print:=cop;
              q:=ck;
          end;
      end;
      end;
      ls:=length(r);
end;
if print<>'' then write(print);
end.